package com.lwj.service.configuration;

import com.lwj.exception.BusinessException;
import com.lwj.mapper.configuration.FileManageMapper;
import com.lwj.model.configuration.FileManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FileManageServiceImpl implements FileManageService {
    @Autowired
    private FileManageMapper fileManageMapper;

    @Override
    public int deleteByPrimaryKey(String fileId) {
        return fileManageMapper.deleteByPrimaryKey(fileId);
    }

    @Override
    public int insert(FileManage record) {
        return fileManageMapper.insert(record);
    }

    @Override
    public int insertSelective(FileManage record) {
        return fileManageMapper.insertSelective(record);
    }

    @Override
    public FileManage selectByPrimaryKey(String fileId,Boolean must) {
        FileManage fileManage = fileManageMapper.selectByPrimaryKey(fileId);
        if(must&&fileManage==null){
            throw new BusinessException("文件不存在");
        }
        return fileManage;
    }

    @Override
    public int updateByPrimaryKeySelective(FileManage record) {
        return fileManageMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(FileManage record) {
        return fileManageMapper.updateByPrimaryKey(record);
    }

    @Override
    public int maxIndex(String relationId) {
        Integer integer = fileManageMapper.maxIndex(relationId);
        return integer==null?0:integer;
    }
}
